<?php

/********************************/
class InvoiceAuth {
/********************************/
    private static $wsdl = "https://test.e-szamla.hu/soap/AuthenticationService.wsdl";
    private static $client = null;
    private static $sid;

    public static function startSession(
        $username,
        $password,
        $sw_company = LEAVE_DEFAULT,
        $sw_name    = LEAVE_DEFAULT,
        $sw_version = LEAVE_DEFAULT,
        $issuer     = LEAVE_DEFAULT
    ) {
        self::$client = new SoapClient(self::$wsdl);

        if ($sw_company == LEAVE_DEFAULT) { $sw_company = "Lancaster Consulting Ltd"; }
        if ($sw_name    == LEAVE_DEFAULT) { $sw_name = "Hungarian Exporters portal"; }
        if ($sw_version == LEAVE_DEFAULT) { $sw_version = "1.0"; }
        if ($issuer     == LEAVE_DEFAULT) { $issuer = null; }

        $result = self::$client->startSession(array(
            username => $username,
            password => $password,
            "sw-company" => $sw_company,
            "sw-name"    => $sw_name,
            "sw-version" => $sw_version,
        ));
        self::$sid = $result->sessionid;
        return $result->sessionid;
    }

    public static function endSession() {
        self::$client->endSession(array(
            sessionid => self::$sid,
        ));
    }
}


?>
